package com.amarsoft.apot.controller;

import com.amarsoft.apot.service.SendSmsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.*;

@RestController
@RequestMapping("/sms")
public class SendSmsController {

    @Autowired
    private SendSmsService sendSmsService;

    /**
     * 批量发送短信
     * @return
     */
    @RequestMapping("/sendsms")
    public String sendSms() {
        boolean flag = false;
        List<String> phones = new ArrayList<>();
        phones.add("17784451642");
        phones.add("15212632851");
        Map<String,Object> map = new HashMap<String,Object>();
        String code = UUID.randomUUID().toString().substring(0, 4);
        map.put("code",code);
        for(String phone : phones) {
            flag = sendSmsService.sendSms(phone, "SMS_205134212", map);
        }
        System.out.println(flag);
        if(flag == true) {
            return "短信发送成功";
        } else {
            return "短信发送失败";
        }
    }

}
